package com.banquetmanagementsystem.controller;

import com.banquetmanagementsystem.common.Utils.TokenUtilProperties;
import com.banquetmanagementsystem.common.constant.MessageConstant;
import com.banquetmanagementsystem.common.exception.CaptchaException;
import com.banquetmanagementsystem.common.response.Result;
import com.banquetmanagementsystem.pojo.dto.UserInfoLoginDTO;
import com.banquetmanagementsystem.service.LoginService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 登录
 *
 * @author tanghaihua
 */

@RestController
public class LoginController {
    @Resource(name = "loginServiceImpl")
    private LoginService loginService;

    @PostMapping("/login")
    public Result<?> login(@RequestBody UserInfoLoginDTO user, HttpServletRequest request) {
        return Result.success(loginService.login(user,request),MessageConstant.LOGIN_SUCCESS);
    }
    @PostMapping("/logout")
    public Result<?> logout(@RequestBody Integer userId) {
        System.out.println(userId);
        loginService.logout(userId);
        return Result.success(null,MessageConstant.LOGOUT_SUCCESS);
    }
}